package com.xiaowen.tool.dto;

/**
 * Created with IntelliJ IDEA.
 * User: yf-wenhao
 * Date: 2024/9/18
 * Time: 下午1:57
 */
public enum  ErrorCode {
    INTERNAL_SERVER_VALID_ERROR(400,"参数错误"),
    INTERNAL_SERVER_ERROR(500,"服务异常"),
    UNAUTHORIZED(401,"未授权"),
    ;

    private Integer code;
    private String msg;

    ErrorCode(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static String getMsg(int msgCode) {
        for (ErrorCode value : ErrorCode.values()) {
            if (value.code.equals(msgCode)) {
                return value.msg;
            }
        }
        return null;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
